<template>
  <div>
    <bbw-table
            :tableData.sync="tableData"
            @onFinish="onFinish"
            :header="header"
    >

    </bbw-table>
  </div>
</template>

<script>
    import api from '../utils/api'
    import {get, post} from '../utils/request'
export default {
    data(){
        return {
            tableData:[],
            column:[

            ],
            header:[
                {
                    label: '编号',
                    value:'number',
                    width:100
                },
                {
                    label: '招聘岗位',
                      value: 'job',

                },
                {
                    label: '证书级别',
                    value:'certificate',

                },
                {
                    label: '航运区域',
                    value:'area',
                },

                {
                    label: '船舶类型',
                    value:'ship_type',
                },
                {
                    label: '招聘公司',
                    value:'recruitment',
                },
                {
                    label: '日期',
                    value:'date',
                    width:200
                },
                ],
            type: 0
        }
    },
    props: {
     // msg: String
    },
    watch:{
        // ['$route.query.type']:{
        //     handler(val){
        //         this.tableData = []
        //         let type = val
        //         this.type = type
        //         console.log(type)
        //         this.getData(type)
        //     },
        //     immediate: true
        //
        // }
    },
    mounted(){
        // let type = this.$route.query.type
        // this.type = type
        // // console.log(this.$route.query.type)
        this.getData()
    },
    methods:{
        getData(type){
            get(api.getJobads).then(res=>{
                this.tableData = res.data
            }).catch(err=>{

            })
        },
        onFinish(data){
            post(api.addJobads,{
                data,
            }).then(res=>{
                this.$message(res.msg)
                this.getData(this.type)
            }).catch(err=>{
                this.getData(this.type)
                this.$message(err.msg||'提交错误')
            })
        }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
